/*******************************************************************************
 * Copyright (c) 2011 TXT e-solutions SpA
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * This work was performed within the IoT_at_Work Project
 * and partially funded by the European Commission's
 * 7th Framework Programme under the research area ICT-2009.1.3
 * Internet of Things and enterprise environments.
 *
 *
 * Authors:
 *     Cristoforo Seccia (TXT e-solutions SpA)
 *
 * Contributors:
 *      Domenico Rotondi (TXT e-solutions SpA)
 *******************************************************************************/
package it.txt.access.capability.wizard.util;

/**
 *
 * @author Cristoforo Seccia (TXT e-solutions SpA)
 */
public class Resources {

    public static final String RESOURCES_ROOT = "/";

    public static final String IMAGES_DIR = RESOURCES_ROOT + "images/";

    public static final String ICONS_16X16_DIR = IMAGES_DIR + "icons_16x16/";

    public static final String ICONS_24X24_DIR = IMAGES_DIR + "icons_24X24/";



    /*private ArrayList<Class<?>> findClasses(File directory) {

    ArrayList<Class<?>> classes = new ArrayList<Class<?>>();

    if (!directory.exists()) {
    return classes;
    }

    File[] files = directory.listFiles();

    for (File file : files) {

    if (!file.isDirectory() && file.getName().endsWith(".jar")) {

    try {

    JarFile jf = new JarFile(file);

    Enumeration<JarEntry> enumeration = jf.entries();

    while (enumeration.hasMoreElements()) {

    JarEntry je = enumeration.nextElement();

    if (je.getName().endsWith(".class")) {

    String entryName = je.getName().replaceAll("/", ".");
    int index = entryName.lastIndexOf(".class");
    entryName = entryName.substring(0, index);


    InputStream in = jf.getInputStream(je);

    byte[] array = new byte[1024];
    ByteArrayOutputStream out =
    new ByteArrayOutputStream(array.length);
    int length = in.read(array);
    while (length > 0) {
    out.write(array, 0, length);
    length = in.read(array);
    }
    Class<?> clazz = defineClass(entryName,
    out.toByteArray(), 0, out.size());

    classes.add(clazz);
    }
    }
    } catch (IOException ex) {
    LOGGER.log(Level.SEVERE, ex.getMessage(), ex);
    }
    }
    }
    return classes;
    }*/


    /*public static void loadAdvailablePlugins(File directory) {

        File[] files = directory.listFiles();

        for (File file : files) {

            if (!file.isDirectory() && file.getName().endsWith(".jar")) {

                try {

                    URL[] jar = new URL[]{file.toURI().toURL()};
                    URLClassLoader loader = URLClassLoader.newInstance(jar);

                    JarFile jf = new JarFile(file);

                    Enumeration<JarEntry> enumeration = jf.entries();

                    while (enumeration.hasMoreElements()) {

                        JarEntry je = enumeration.nextElement();

                        if (je.getName().endsWith(".class")) {

                            String cName = je.getName().replaceAll("/", ".");
                            int index = cName.lastIndexOf(".class");
                            cName = cName.substring(0, index);
                            Class<?> classToLoad = loader.loadClass(cName);

                            try {
                                Object instance = classToLoad.newInstance();
                                if (instance instanceof ICapabilityPlugin) {
                                    ICapabilityPlugin icp = (ICapabilityPlugin) instance;
                                    String plugInName = icp.getPluginName();
                                    LOGGER.log(Level.INFO, "Found Plugin: {0}", plugInName);
                                    PLUGIN_LIST.add(icp);
                                }
                            } catch (InstantiationException ex) {
                                LOGGER.log(Level.WARNING, ex.getMessage(), ex);
                            } catch (IllegalAccessException ex) {
                                LOGGER.log(Level.WARNING, ex.getMessage(), ex);
                            }
                        }
                    }
                } catch (IOException ex) {
                    LOGGER.log(Level.SEVERE, ex.getMessage(), ex);
                } catch (ClassNotFoundException ex) {
                    LOGGER.log(Level.SEVERE, ex.getMessage(), ex);
                }
            }
        }
    }*/
}
